package com.packet.service.impl;

import com.packet.mapper.FinanceQueryMapper;
import com.packet.pojo.Examine;
import com.packet.pojo.Staff;
import com.packet.pojo.Trip;
import com.packet.service.FinanceQueryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @className:FinanceQueryServiceImpl
 * @Author:wallet_packet Date:2023-12-07 16:52
 * @Describe:
 */
@Service
public class FinanceQueryServiceImpl implements FinanceQueryService {
    @Autowired
    FinanceQueryMapper financeQueryMapper;

    @Override
    public List<Trip> selectTripByChoice(Map<String, Object> map) {
        return financeQueryMapper.selectTripByChoice(map);
    }

    @Override
    public Map<String, Object> handleChoice(Map<String, Object> map) {
        HashMap<String, Object> hashMap = new HashMap<>();
        if(map.get("contentDateChoice").equals("")){
            //设置时间为任意时间都是可以的
            hashMap.put("tdate",null);
        } else {
            hashMap.put("tdate",map.get("contentDateChoice"));
        }


        if(map.get("contentUrgency").equals("low")){
            hashMap.put("urgency",2);

        }else if(map.get("contentUrgency").equals("middle")){
            hashMap.put("urgency",1);
        }else if(map.get("contentUrgency").equals("high")){
            hashMap.put("urgency",0);
        }else{
            hashMap.put("urgency",null);
        }

        if(map.get("contentCorrectChoice").equals("alreadyCorrectY")){
            hashMap.put("state",6);
        } else if (map.get("contentCorrectChoice").equals("alreadyCorrectV")) {
            hashMap.put("state",9);
        } else if (map.get("contentCorrectChoice").equals("noCorrect")){
            hashMap.put("state",5);
        }else {
            hashMap.put("state",null);
        }
        System.out.println(hashMap.get("date"));
        System.out.println(hashMap.get("urgency"));
        System.out.println(hashMap.get("state"));


        return hashMap;
    }

    @Override
    public List<Trip> selectTripNoCorrect() {
        return financeQueryMapper.selectTripNoCorrect();
    }

    @Override
    public List<Trip> selectTripAll() {
        return financeQueryMapper.selectTripAll();
    }

    @Override
    public List<Trip> selectTripAreadyCorrect() {
        return financeQueryMapper.selectTripAreadyCorrect();
    }

    @Override
    public List<Staff> selectStaff() {
        return financeQueryMapper.selectStaff();
    }

    @Override
    public int[] queryLimitPage(String choice,int [] pre) {
        int [] now = new int[pre.length];
        if(choice.equals("next")){
            for (int i = 0; i < pre.length; i++) {
                now[i] = pre[i]+1;
            }
        }else{
            if(pre[0]==0){
                return pre;
            }
        }
        return  now;
    }

    @Override
    public int selectCount() {
        return financeQueryMapper.selectCount();
    }

    @Override
    public List<Examine> selectExamineAll() {
        return financeQueryMapper.selectExamineAll();
    }
}
